﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace com.qbengo.utility.nodepicker
{
    class NodeDistance
    {
        private int id;
        private int aKey;
        private int bKey;
        private NodeGraphic aNode;
        private NodeGraphic bNode;
        private float distance;

        public NodeDistance(int id, NodeGraphic aNode, NodeGraphic bNode)
        {
            this.id = id;
           // this.aKey = aNode.Key;
           // this.bKey = bNode.Key;
            this.aNode = aNode;
            this.bNode = bNode;
        //    aNodeID = aNode.ID;
          //  bNodeID = bNode.ID;
            distance = CalculateDistance(aNode, bNode);
        }
        /// <summary>
        /// 计算两个节点间的距离
        /// </summary>
        /// <param name="aNode"></param>
        /// <param name="bNode"></param>
        /// <returns></returns>
        private float CalculateDistance(NodeGraphic aNode, NodeGraphic bNode)
        {
            return (float)Math.Sqrt(Math.Pow(aNode.X - bNode.X, 2)
                + Math.Pow(aNode.Y - bNode.Y, 2));
        }

        public int ID
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }

        public int ANodeID
        {
            get
            {
                return  aNode.ID;
            }
            set
            {
                aNode.ID = value;
            }
        }

        public int BNodeID
        {
            get
            {
                return bNode.ID;
            }
            set
            {
                bNode.ID = value;
            }
        }


        public NodeGraphic ANode
        {
            get
            {
                return aNode;
            }
            set
            {
                aNode = value;
            }
        }

        public NodeGraphic BNode
        {
            get
            {
                return bNode;
            }
            set
            {
                bNode = value;
            }
        }


        public float Distance
        {
            get
            {
                return distance;
            }
            set
            {
                distance = value;
            }
        }
        //public static bool operator ==(NodeDistance nodeDistance1, NodeDistance nodeDiatance2)
        //{
        //    if ((nodeDistance1.ANode == nodeDiatance2.ANode && nodeDistance1.BNode == nodeDiatance2.BNode)
        //        || (nodeDistance1.ANode == nodeDiatance2.BNode && nodeDistance1.BNode == nodeDiatance2.ANode))
        //        return true;
        //    else
        //        return false;
        //}

        //public static bool operator !=(NodeDistance nodeDistance1, NodeDistance nodeDistance2)
        //{
        //    return !(nodeDistance1 == nodeDistance2);
        //}
    }
}
